/*非ChenHacker不得编辑*/
#include<fstream>
#include<string>
using namespace std;
class SaveData {//数据存储类
public:
	vector<string> VarList;
	string CludeName;
	string GameName;//程序名字
	string OpenData;//数据路径
	string OpenDataTemp;
	ofstream List;
	
	int Read() {
		ifstream READ(&OpenData[0]);
		string ReadName;
		while(READ>>ReadName) {
			VarList.push_back(ReadName);
			while(READ.get()!='\n');
		}
		READ.close();
		return 0;
	}
	
	SaveData(string CludeNameTemp) {//CludeNameTemp为当前类所管理的数据库名
		GameName="GuGuGameData";
		CludeName=CludeNameTemp;
		OpenData+="C:\\"+GameName+"\\"+CludeName+"\\list.dat\0";
		fstream MD(&OpenData[0],ios::in);
		if(!MD) {
			string OpenOld=OpenData;
			OpenData="md ";
			OpenData+="C:\\"+GameName+"\\"+CludeName+"\0";
			system(&OpenData[0]);
			MD.close();
			ofstream MDD(&OpenOld[0]);
			MDD.close();
		}
		OpenData="C:\\"+GameName+"\\"+CludeName+"\\list.dat\0";
		Read();
		List.open(&OpenData[0],ios::app);
		OpenData="C:\\"+GameName+"\\"+CludeName+"\\";
	}
	~SaveData() {
		List.close();
	}
	char* GetOpenData(string Key) {//得到路径
		OpenDataTemp=OpenData+Key+".dat\0";
		return &OpenDataTemp[0];
	}
	int NewVar(string Key) {//新建一个变量
		List<<Key<<endl;
		return 0;
	}
	int SaveVoid(char* Data,string Key,int DataSize);//万能存储函数（支持自定义类型）
	
	int SaveInt(int Data,string Key);//存储单个变量
	int SaveString(string Data,string Key);
	int SaveChar(char Data,string Key);
	
	int SaveIntS(int* Data,string Key,int DataSize);//存储数组
	int SaveStringS(string* Data,string Key,int DataSize);
	int SaveCharS(char* Data,string Key,int DataSize);
	
	int SaveVectorInt(vector<int> Data,string Key);//存储vector
	int SaveVectorString(vector<string> Data,string Key);
	int SaveVectorChar(vector<char> Data,string Key);
	
	
	int GetVoid(char* Data,string Key,int DataSize);//万能获取变量
	
	int GetInt(int& Data,string Key);//获取单个变量
	int GetString(string& Data,string Key);
	int GetChar(char& Data,string Key);
	
	int GetIntS(int* Data,string Key,int DataSize);//获取数组
	int GetStringS(string* Data,string Key,int DataSize);
	int GetCharS(char* Data,string Key,int DataSize);
	
	int GetVectorInt(vector<int>& Data,string Key);//获取vector
	int GetVectorString(vector<string>& Data,string Key);
	int GetVectorChar(vector<char>& Data,string Key);
};
int SaveData::SaveVoid(char* Data,string Key,int DataSize) {
	ofstream SAVE(GetOpenData(Key),ios::binary);
	SAVE.write(Data,DataSize);
	SAVE.close();
	NewVar(Key);
	return 0;
}

int SaveData::SaveInt(int Data,string Key) {
	SaveVoid((char*)&Data,Key,sizeof(int));
	return 0;
}
int SaveData::SaveString(string Data,string Key) {
	SaveVoid((char*)&Data[0],Key,sizeof(char)*Data.size());
	return 0;
}
int SaveData::SaveChar(char Data,string Key) {
	SaveVoid((char*)&Data,Key,sizeof(char));
	return 0;
}

int SaveData::SaveIntS(int* Data,string Key,int DataSize) {
	SaveVoid((char*)Data,Key,DataSize);
	return 0;
}
int SaveData::SaveStringS(string* Data,string Key,int DataSize) {
	SaveVoid((char*)Data,Key,DataSize);
	return 0;
}
int SaveData::SaveCharS(char* Data,string Key,int DataSize) {
	SaveVoid((char*)Data,Key,DataSize);
	return 0;
}

int SaveData::SaveVectorInt(vector<int> Data,string Key) {
	SaveVoid((char*)&Data,Key,sizeof(Data));
	return 0;
}
int SaveData::SaveVectorString(vector<string> Data,string Key) {
	SaveVoid((char*)&Data,Key,sizeof(Data));
	return 0;
}
int SaveData::SaveVectorChar(vector<char> Data,string Key) {
	SaveVoid((char*)&Data,Key,sizeof(Data));
	return 0;
}




int SaveData::GetVoid(char* Data,string Key,int DataSize) {
	ifstream GET(GetOpenData(Key),ios::binary);
	GET.read(Data,DataSize);
	GET.close();
	return 0;
}
	
int SaveData::GetInt(int& Data,string Key) {
	GetVoid((char*)&Data,Key,sizeof(Data));
	return 0;
}
int SaveData::GetString(string& Data,string Key) {
	ifstream GET(GetOpenData(Key));
	GET>>Data;
	GET.close();
	return 0;
}
int SaveData::GetChar(char& Data,string Key) {
	GetVoid((char*)&Data,Key,sizeof(Data));
	return 0;
}

int SaveData::GetIntS(int* Data,string Key,int DataSize) {
	GetVoid((char*)Data,Key,sizeof(Data));
	return 0;
}
int SaveData::GetStringS(string* Data,string Key,int DataSize) {
	GetVoid((char*)Data,Key,sizeof(Data));
	return 0;
}
int SaveData::GetCharS(char* Data,string Key,int DataSize) {
	GetVoid((char*)Data,Key,sizeof(Data));
	return 0;
}

int SaveData::GetVectorInt(vector<int>& Data,string Key) {
	GetVoid((char*)&Data,Key,sizeof(Data));
	return 0;
}
int SaveData::GetVectorString(vector<string>& Data,string Key) {
	GetVoid((char*)&Data,Key,sizeof(Data));
	return 0;
}
int SaveData::GetVectorChar(vector<char>& Data,string Key) {
	GetVoid((char*)&Data,Key,sizeof(Data));
	return 0;
}

























